import MaxHeap from "./MaxHeap";

export default class PriorityQueue2<T> {
  private heap: MaxHeap<T> = new MaxHeap();

  enqueue(value: T) {
    this.heap.insert(value);
  }

  dequeue(): T | undefined {
    return this.heap.extract();
  }

  peek(): T | undefined {
    return this.heap.peek();
  }

  isEmpty(): boolean {
    return this.heap.isEmpty();
  }

  size(): number {
    return this.heap.size();
  }
}

// 外部传入对象，对象中实现valueOf方法用于比较
